package com.zzedu.enmuns;

import com.zzedu.common.utils.StringUtils;

import java.util.Arrays;

/**
 * 验证码枚举
 */
public enum VerificationCodeEnums {
    APP_LOGIN_VERIFICATION_CODE("APP_LOGIN_VERIFICATION_CODE", "登录验证码", "2469810"),
    ;

    private final String code;

    private final String desc;

    /**
     * 短信模版ID
     */
    private final String templateId;

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    VerificationCodeEnums(String code, String desc, String templateId) {
        this.code = code;
        this.desc = desc;
        this.templateId = templateId;
    }

    public String getTemplateId() {
        return templateId;
    }

    public static VerificationCodeEnums getCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        return Arrays.stream(VerificationCodeEnums.values()).filter(e -> e.code.equals(code)).findFirst().orElse(null);
    }
    @Override
    public String toString() {
        return String.valueOf(code); // 或者 name(), 或者 desc
    }
}
